<?php

namespace app\command;
use think\App;
use think\console\Command;
use think\console\Input;
use think\console\Output;
use app\order\logic\OrderCostLogic;
use think\facade\Cache;
class DailyStatisticsOfAdv extends Command
{

    protected function configure()
    {
        $this->setName('DailyStatisticsOfAdv')
            ->setDescription('DailyStatisticsOfAdv');
    }

    protected function execute(Input $input, Output $output)
    {
        //判断广告创意统计
        // (new OrderCostLogic())->JudgingAdvCreativity();die;
        // // 临时洗数据-----广告用户
        // 更新3天以内
        (new OrderCostLogic())->DailyStatisticsOfAdv_admin(1);
        //更新遗漏数据
        (new OrderCostLogic())->DailyStatisticsOfAdv_admin(2);
        //更新3天内广告分配变动
        (new OrderCostLogic())->DailyStatisticsOfAdv_admin(3);

        
        //5小时更新一次
        $ViewTodaysUpdates = Cache::store('redis')->get('ViewTodaysUpdates');
        if (empty($ViewTodaysUpdates)) {  
            Cache::store('redis')->set('ViewTodaysUpdates', 1, 3600 * 2);
        }else{
            echo '时间没到先不更新';die;
        }

        //查看今日更新---fb广告系列
        (new OrderCostLogic())->ViewTodaysUpdates();
        //手动更新广告----更新广告系列明细--符合规则的
        (new OrderCostLogic())->UpdateAdvCampaign();
        //手动更新广告----更新广告明细
        (new OrderCostLogic())->UpdateAdvinfo();
        //手动更新广告----两天以内的---fb广告系列---花费
        (new OrderCostLogic())->Adaccounts_day();
        //手动更新广告----两天以内的---fb广告---花费
        (new OrderCostLogic())->Adinfoaccounts_day();
        //判断广告创意统计
        // (new OrderCostLogic())->JudgingAdvCreativity();

        $ViewTodaysUpdates2 = Cache::store('redis')->get('ViewTodaysUpdates2');
        if (empty($ViewTodaysUpdates2)) {  
            Cache::store('redis')->set('ViewTodaysUpdates2', 1, 3600 * 24);
        }else{
            echo '时间没到先不更新';die;
        }

        //拉取广告系列
        // (new OrderCostLogic())->GetAdCampaignsList();
        //拉取广告
        // (new OrderCostLogic())->GetAdCinfoList();
    }
}